﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="RunExe.aspx.cs" Inherits="tjb.WebTest.RunExe" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    </div>

    <script language="JavaScript">

        function appCmd(appPath) {
            try {
                var myShell = new ActiveXObject("WScript.Shell");
                //myShell.Run("cmd /c start \"" + appPath + "\"");
                myShell.Exec("\"" + appPath + "\"");
                myShell = null;
            }
            catch (e) {
                alert((e.message || e.description || "程序不存在") + "\n请参考《关于IE执行客户端应用程序的注意事项》文档");
            }
        }
        function appRun() {
            var n = arguments.length;
            if (n > 0) {
                for (var i = 0; i < n; i++) {
                    var obj = arguments[i];
                    if (typeof (obj) == "string")
                    { appCmd(obj); }
                    else {
                        alert("路径必须为string类型！");
                    }
                }
            }
        } 
    </script>

    <button onclick="appRun()">
        test</button>
    </form>
</body>
</html>
